package com.java.base.lock;

import java.util.concurrent.locks.ReentrantLock;

public class ReentrantLockDemo {
    static ReentrantLock lock = new ReentrantLock();

    public static void main(String[] args) {

        for (int i = 0; i < 2; i++) {
            new Thread(() -> {
                System.out.println(Thread.currentThread().getName() + ":try:" + lock.isLocked());
                System.out.println(Thread.currentThread().getName() + ":" + lock.tryLock());
                System.out.println(Thread.currentThread().getName() + ":end");
            }).start();
        }


        System.out.println(lock.isLocked());

    }

}
